#pragma once

#include <QItemDelegate>

class WidgetDelegate : public QItemDelegate {
    Q_OBJECT
public:
    WidgetDelegate(QItemDelegate *parent = nullptr);
    WidgetDelegate(QStringList list, QItemDelegate *parent = nullptr);
    ~WidgetDelegate();


    // 创建编辑器
    virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
    // 设置编辑器数据
    virtual void setEditorData(QWidget *editor, const QModelIndex &index) const override;
    // 更新编辑器集合属性
    virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
    // 设置模型数据
    virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;


    /*****根据项目需求增添辅佐函数*****/

    // 获取索引数据
    QString getCurrentComboBoxData(int index);
    // 插入
    void insertCoBData(QString str);
    // 删除
    void removeCobData(QString str);

private:
    QStringList m_comboBoxList;
};

